﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

using System.ComponentModel;

namespace ScrumTable.BL.DM.Test.DataManagement
{
    #region Usings

    using ScrumTable.BL.DM.DataManagement;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    #endregion

    /// <summary>
    /// This class mocks the domain collection event handling features.
    /// </summary>
    internal class DomainCollectionEventMock<T>
        where T : DomainBase, new()
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        private bool _eventCalled = false;
        private readonly T _element;

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        internal bool EventCalled
        {
            get { return _eventCalled; }
        }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates a new DomainCollectionEventMock instance.
        /// </summary>
        internal DomainCollectionEventMock(T element)
        {
            _element = element;
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        internal void PerformEventCheck(object sender, PropertyChangedEventArgs e)
        {
            Assert.IsNotNull(sender);
            Assert.IsNotNull(e.PropertyName);
            Assert.IsTrue(_element.Equals(sender));
            _eventCalled = true;
        }

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}
